<template>
  <div class="app-container">
    <div class="table-container">
      <base-list
        ref="table"
        url="/huwei"
        :options="options"
        :columns="columns"
        :format="format"
        :rules="rules"
        permission="huwei"
        @reloadOptions="handleGetOptions"
      >
        <template slot="raw_actions" slot-scope="scope">

        </template>
      </base-list>
    </div>
  </div>
</template>

<script>
import { requestBase } from '@/api/common'
import permission from '@/directive/permission/index.js' // 权限判断指令
import waves from '@/directive/waves' // waves directive
import BaseList from '@/components/BaseList'

export default {
  name: 'ProjectInfo',
  components: { BaseList },
  directives: { permission, waves },
  data() {
    return {
      buildLoading: false,
      columns: [
        { show: true, queryable: true, edit: true, width: 200, key: 'name', label: '姓名', type: 'WORD' },
        { show: true, queryable: true, edit: true, width: 200, key: 'code', label: '编号', type: 'WORD' },
        { show: true, queryable: true, edit: true, width: 200, key: 'image', label: '图片', type: 'IMAGE' },
        { show: true, queryable: true, edit: true, width: 200, key: 'height', label: '身高', type: 'WORD' },
        { show: true, queryable: true, edit: true, width: 200, key: 'weight', label: '体重', type: 'WORD' },
        { show: true, queryable: true, edit: true, width: 200, key: 'wechat', label: '微信', type: 'WORD' },
        { show: true, queryable: true, edit: true, width: 200, key: 'phone', label: '手机号', type: 'WORD' },
        { show: true, queryable: true, edit: true, width: 200, key: 'state', label: '状态', type: 'DICTIONARY', optionKey: 'stateOptions' },
        { show: true, queryable: false, edit: true, minWidth: 300, key: 'extra', label: '其他条件', type: 'LONG_WORD' },
        { show: true, queryable: false, edit: true, minWidth: 300, key: 'requirement', label: '基本条件', type: 'LONG_WORD' },
        { show: false, queryable: false, edit: true, width: 200, key: 'description', label: '介绍', type: 'LONG_TEXT' },
      ],
      format: {
      },
      rules: {
        add: {
        },
        edit: {
        }
      },
      options: {
        stateOptions: [{id: 'WAIT_PUBLISH', name: '未发布', type: 'info'}, {id: 'SIGN_UP', name: '已发布', type: 'success'}]
      }
    }
  },

  created() {
    this.handleGetOptions()
  },
  mounted() {
  },
  methods: {
    handleGetOptions() {
      this.options = JSON.parse(localStorage.getItem('allOptions')) || this.options
    },
    handleBuildStart(id) {
      this.buildLoading = true
      requestBase({
        url: '/generate/project/' + id + '/build',
        method: 'POST'
      }).then(res => {
        this.buildLoading = false
      }).catch(() => {
        this.buildLoading = false
      })
    }
  }
}
</script>

